home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / twinopus / dopus / makedir.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1995-07-13  |  2.8 KB  |  123 lines

  1. /*
  2.  *
  3.  * Makes a directory with TwinExpress from DOpus.
  4.  *
  5.  * (c) 1994 by K.P. van Beem (2:280/464.2, patrick.van.beem@aobh.xs4all.nl)
  6.  *
  7.  * Based on the DOpusLhaARexx package by Geoff Seeley (but you can better
  8.  * use GuiArc in stead of DOpus and a script, to deal with archives)
  9.  *
  10.     - Bug Fix by Ray Abram
  11.       - Will work in a Twin or a DOpus file list
  12.     - Prompting tells if dir is to be local or remote
  13.  */
  14.  
  15. trace ?R
  16.  
  17. DOpusPort   = 'DOPUS.1'
  18.  
  19. if ~show(l,"rexxsupport.library") then
  20.     call addlib("rexxsupport.library",0,-30,0)
  21. if showlist('Ports', DOpusPort) = 0 then do
  22.    say 'Directory Opus Arexx port not found. Aborting.'
  23.    call CleanUp
  24. end
  25.  
  26. address 'DOPUS.1'
  27. options results
  28.  
  29. /* setup DOpus window and tell user what's happening */
  30. Busy on
  31. TopText "Creating (sub)directory..."
  32.  
  33. /* Get the current path to create the dir */
  34. 'Status 6 -1'
  35. GetEntry Result
  36. FilePath = Result
  37. if left(FilePath,1) ~= '*' then do
  38.    TopText "You are not in a Twin directory. ??"
  39.    makedir
  40.    call CleanUp
  41. end
  42.  
  43. /* get the path from the string */
  44. FilePath = SubStr(FilePath,2)
  45. DA = EnterDir(FilePath)
  46.  
  47. /* get more descriptive text */
  48. if DA = '~' then
  49.    Question = '"Enter new Remote Directory Name..."'
  50. else
  51.    Question = '"Enter new Local Directory Name..."'
  52.  
  53. /* Get the name of the directory to create */
  54. getstring  Question
  55. Directory = Result
  56. if Directory="" | rc~=0 then do
  57.    TopText "Aborted or You have to give a Directory Name."
  58.    call CleanUp
  59. end
  60.  
  61. /* Check for spaces in the filename */
  62. if words(Directory) > 1 then do
  63.    request "Spaces in a Directory name are not allowed !!"
  64.    call CleanUp
  65. end
  66.  
  67. DA = EnterDir(FilePath)
  68. address command 'echo >PPipe: MkDir' Quote(DA || Directory)
  69.  
  70. 'DisplayDir -1'
  71. address command "rx Rexx:DOpus/Reread.rexx"
  72. call CleanUp
  73.  
  74. exit
  75.  
  76. /*---------------------------------------------------------------------------*/
  77.  
  78. CleanUp: /* Remove any files and exit */
  79.  
  80.    Busy off
  81.  
  82.    exit
  83.  
  84. return
  85.  
  86. /*--------------------------------------------------------------------------*/
  87.  
  88. Quote: procedure /* add quotes to string */
  89.  
  90.    parse arg string
  91.  
  92. return '"'||string||'"'
  93.  
  94. /*--------------------------------------------------------------------------*/
  95.  
  96. /* Cd into the sent Directory path
  97.    - this is needed, as TWIN has a command parameter limit of 30 characters,
  98.       and as we all know AmigaDos file & paths can easily go over this limit !!*/
  99.  
  100. EnterDir: procedure
  101.  
  102.    parse arg Dev ':' Path
  103.  
  104.    /* get the 1st character to address the local or remote machine correctly */
  105.    if left(Dev,1) = '~' then
  106.       sbit = '~'
  107.      else
  108.       sbit = ''
  109.  
  110.    /* does the passed name have a DEVICE in it ? */
  111.    if Dev ~= '' then
  112.       address command 'echo >PPipe: cd' Dev || ':'
  113.  
  114.    do until (t2 = '')
  115.       parse var Path t1 '/' t2
  116.       path = t2
  117.       if t1 ~= '' then
  118.          address command 'echo >PPipe: cd' sbit || t1
  119.    end
  120.  
  121. return sbit
  122.  
  123.